<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>XHR Example - Polling</title>
	</head>
	<body>
		
		<script type="text/javascript" src="../xhr.js"></script>
		<script>
			// fiji.xhr instance
			var XHR = new fiji.xhr();
			
			// callback function
			callback = function(req) {
			  if (req.xhr.readyState == 4) {
			    if (req.xhr.status == 200) {
			      // poll server every 1/2 seconds
			      setTimeout(function() {
				  	 XHR.req('post', 'echo.php', callback);
			         XHR.send({'param': 'value'});
			      }, 500);
			    } else {
			      alert('HTTP Error: '+req.xhr.responseCode);
			    }
			  }
			};
			// set the request parameters
			XHR.req('post', 'echo.php', callback);
			// send initial request
			XHR.send({'param': 'value'});
		</script>

	</body>
</html>
